#
# GambatteDroid
# Copyright 2011 Stephen Damm (Halsafar) 
# All rights reserved.
# shinhalsafar@gmail.com
#

# OPTIONS


# STORE PATHS
LOCAL_PATH := $(call my-dir)
ORG_PATH := $(LOCAL_PATH)

# BUILD ALL EXTERNAL LIBS
include $(CLEAR_VARS)
include $(call all-makefiles-under,$(LOCAL_PATH))


# BUILD EMU LIB
include $(CLEAR_VARS)
LOCAL_PATH := $(ORG_PATH)/

LOCAL_MODULE_TAGS := user

LOCAL_ARM_MODE := arm

LOCAL_MODULE := libemu

MY_FILES 	:=	\
				$(wildcard $(LOCAL_PATH)/../libgambatte/src/sound/*.cpp) \
				$(wildcard $(LOCAL_PATH)/../libgambatte/src/video/*.cpp) \
				$(wildcard $(LOCAL_PATH)/../libgambatte/common/resample/src/*.cpp) \
				$(wildcard $(LOCAL_PATH)/../libgambatte/src/*.cpp) \
				$(wildcard $(LOCAL_PATH)/../libgambatte/src/file/unzip/*.c)
						
		
# Correct the file names		
MY_FILES := $(MY_FILES:$(LOCAL_PATH)/%=%) 


# Emulator Engine source files that we will compile.
LOCAL_SRC_FILES := \
			$(MY_FILES) \
			../libgambatte/src/file/file.cpp \
			EmulatorBridge.cpp \
			GraphicsDriver.cpp \
			Application.cpp \
			InputHandler.cpp \
			Quad.cpp		 	
	            
	                  
# Debug
#LOCAL_CFLAGS += -g

# Compiler flags.
LOCAL_CFLAGS := -I. \
				-I$(LOCAL_PATH)/../libgambatte/include \
				-I$(LOCAL_PATH)/../libgambatte/common				
				#-D_STLP_HAS_WCHAR_T -D_GLIBCXX_USE_WCHAR_T
	
	
# Optimization flags
LOCAL_CFLAGS += -O3 \
				-ffast-math \
				-fomit-frame-pointer \
				-fvisibility=hidden \
				-funit-at-a-time \
				-finline-functions
				#-mfloat-abi=softfp \
				#-mfpu=neon
				#--param inline-unit-growth=1000 \
				#--param large-function-growth=5000 \
				#--param max-inline-insns-single=2450
				
				
# Compiler Warning flags
#LOCAL_CFLAGS += -Winline
LOCAL_CFLAGS += -Wno-write-strings


# Custom Emulator Flags
LOCAL_CFLAGS += -DHALDROID -DANDROID -D_STLP_HAS_WCHAR_T -D_GLIBCXX_USE_WCHAR_T -DHAVE_STDINT_H -DUSE_PIX_RGB565 -DSysDDec=float


# GAMBATTE Flags
LOCAL_CFLAGS += -DLSB_FIRST -DFRAMESKIP $(MACHDEP)


# Copy C Flags to CXX flags
LOCAL_CPPFLAGS := $(LOCAL_CFLAGS)
LOCAL_CXXFLAGS := $(LOCAL_CFLAGS)
     

# Native libs to link to
LOCAL_LDLIBS := -lz -llog -lGLESv2

# All of the shared libraries we link against.
LOCAL_SHARED_LIBRARIES := libzip libgnupng

                   
# Static libraries.              
LOCAL_STATIC_LIBRARIES :=   

# Don't prelink this library.  For more efficient code, you may want
# to add this library to the prelink map and set this to true. However,
# it's difficult to do this for applications that are not supplied as
# part of a system image.
LOCAL_PRELINK_MODULE := false


include $(BUILD_SHARED_LIBRARY)


